package com.cherrish.demo.thread;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

/**
 * @author cherrish
 * @time 2019-02-27 14:05
 * @name TestThread1
 * @desc:
 */
public class TestThread1 {
    public static void main(String[] args) {

        ExecutorService executorService = Executors.newFixedThreadPool(10);
        for (int i = 0; i < 100; i++) {
            executorService.submit(new Runnable() {
                @Override
                public void run() {
                    System.out.println(Thread.currentThread().getName() + ": Hello");
                }
            });
        }
/**
  * 如果不再需要新任务，请适当关闭executorService并拒绝新任务
  */
        executorService.shutdown();
    }

}
